package com.deep.transaction.demo8.service.impl;


import com.deep.transaction.demo8.dao.IUserDao;
import com.deep.transaction.demo8.service.ILogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class LogServiceImpl implements ILogService {
    @Autowired
    IUserDao userDao;

    @Override
    // 如果事务传播行为是挂起事务  需要将父事务方法和子事务方法写在不同的类里面
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public void log() {
        userDao.subBalance("33333333");
        System.out.println("新事务执行了");
    }
}
